<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <script>
        /*--------------------- 正则表达式 ------------------------*/
        function test() {
            // 以abc开头
            var regExp = /^abc/
            console.log("/^abc/ = " + regExp.test('abcsss'))

            // 以abc结尾
            var regExp2 = /abc$/
            console.log("/abc$/ = " + regExp2.test("ssabc"))

            // 以abc开头且结尾的只能是abc
            var regExp3 = /^abc$/
            console.log('/^abc$/ = ' + regExp3.test('abc'))
        } 

        /*--------------------- rest、spread参数 ------------------------*/
        /*-------------- rest参数使用在形参上，可以理解为java中的可变参数 ----------------*/
        let test2 = function(a,b,...arg) {
            console.log(`a = ${a}, b = ${b}, c = ${arg}`)
        }
        /*-------------- spread参数使用在实参上 ----------------*/
        let test3 = function(){
            arr1 = [1,2]
            arr2 = [3,4]
            arr3 = [...arr1, ...arr2]
            console.log(arr3)
        }
    </script>
</head>
<body>
    <button onclick="test()">正则表达式</button>
    <button onclick="test2(1,2,3,4)">rest参数</button>
    <button onclick="test3()">spread参数</button>
</body>
</html>